package com.monlyu.action.programming;

import java.util.Date;
import java.util.List;

import com.monlyu.action.PageAction;
import com.monlyu.bo.ProgrammingBo;
import com.monlyu.model.CountPhotoModel;
import com.monlyu.model.GradeManuscriptModel;
import com.monlyu.model.ProgrammingModel;
import com.monlyu.model.SearchManuscriptModel;
import com.monlyu.vo.Manuscript;
import com.monlyu.vo.ProStaffInfo;
import com.monlyu.vo.Progm2GaoJian;
import com.monlyu.vo.Programming;

/*******************************************************************************
 * 
 * <b>功能描述☞</b>新闻编排节目单的查询<br>
 * 
 * <b>开发公司☞</b>重庆唯尼科技有限公司<br>
 * <b>版权☞</b>本文件归重庆唯尼科技有限公司所有<br>
 * <b>项目名☞</b>news<br>
 * <b>文件路径☞</b>com.monlyu.action.programming.ProgramAction.java<br>
 * <b>开发日期☞</b>2010-2-11 <br>
 * 
 * @author chendan
 * @since JDK 5
 * @version 1.0.8
 * 
 ******************************************************************************/
public class SearchProgramAction extends PageAction {

	/** 编排的节目单 */
	private Programming programming;

	private ProgrammingBo programmingBo;

	private List<Progm2GaoJian> progm2GaoJians;

	private Object[] progm2GaoJiansA;

	private Manuscript manuscript;

	/** 稿件id列表 */
	private String idlist;

	private Date beginDate;

	private Date endDate;

	private ProStaffInfo proStaffInfo;

	private ProgrammingModel programmingModel;

	private SearchManuscriptModel searchManuscriptModel;

	private List<GradeManuscriptModel> gradeManuscriptModels;

	private List<Programming> programmings;

	/** 栏目详细信息编排页面，检测是否有调整稿件顺序的权限 */
	private boolean changeOrder;

	private List<CountPhotoModel> countList;

	private String userId;

	private int used;

	private Long manusId;

	public Long getManusId() {
		return manusId;
	}

	public void setManusId(Long manusId) {
		this.manusId = manusId;
	}

	public int getUsed() {
		return used;
	}

	public void setUsed(int used) {
		this.used = used;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public List<CountPhotoModel> getCountList() {
		return countList;
	}

	public void setCountList(List<CountPhotoModel> countList) {
		this.countList = countList;
	}

	public SearchManuscriptModel getSearchManuscriptModel() {
		return searchManuscriptModel;
	}

	public void setSearchManuscriptModel(
			SearchManuscriptModel searchManuscriptModel) {
		this.searchManuscriptModel = searchManuscriptModel;
	}

	public ProgrammingModel getProgrammingModel() {
		return programmingModel;
	}

	public void setProgrammingModel(ProgrammingModel programmingModel) {
		this.programmingModel = programmingModel;
	}

	public Date getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public void setProgrammingBo(ProgrammingBo programmingBo) {
		this.programmingBo = programmingBo;
	}

	@Override
	public String execute() throws Exception {
		return view("selectGaoJian.jsp");
	}

	/**
	 * 查询待选稿件
	 * 
	 * @return
	 * @since chendan 2010-2-11
	 */
	public String search() {
		programming = programmingBo.getProgramming(programming);
		Object[] objects = programmingBo.getManuscript(manuscript, beginDate,
				endDate, programming, used);
		setChangeOrder(programmingBo.checkUser(programming));
		return json(new Object[] { objects[0], objects[1], programming,
				changeOrder });
	}

	/**
	 * 新闻编排节目单的稿件查询
	 * 
	 * @return
	 * @since chendan 2010-2-11
	 */
	public String searchProgm2GaoJian() {
		// 查询progm2GaoJian表
		if (programming != null) {
			if (programming.getDate() != null
					&& programming.getColumn() != null) {
				programming = programmingBo.getProgramming(programming);
			} else if (programming.getId() != null) {
				programming = programmingBo.getProgramming(programming.getId());
			}
			programmingBo.check(programming);
			setChangeOrder(programmingBo.checkUser(programming));
			progm2GaoJians = programmingBo.searchProgm2GaoJian(programming
					.getId());
			progm2GaoJiansA = progm2GaoJians.toArray();
		}
		return view("editProgram.jsp");
	}

	/**
	 * 查询新闻编排节目单信息及稿件信息
	 * 
	 * @return
	 * @since chendan 2010-2-15
	 */
	public String searchProgram() {
		if (programming != null) {
			if (programming.getDate() != null
					&& programming.getColumn() != null) {
				programming = programmingBo.getProgramming(programming);
			} else if (programming.getId() != null) {
				programming = programmingBo.getProgramming(programming.getId());
			}
			progm2GaoJians = programmingBo.searchProgm2GaoJian(programming
					.getId());
		}
		return view("listProgram.jsp");
	}

	/**
	 * 查看新闻导语部分
	 * 
	 * @return
	 * @since chendan 2010-2-16
	 */
	public String searchDaoYu() {
		if (programming != null) {
			if (programming.getDate() != null
					&& programming.getColumn() != null) {
				programming = programmingBo.getProgramming(programming);
			} else if (programming.getId() != null) {
				programming = programmingBo.getProgramming(programming.getId());
			}
			programmingBo.check(programming);
			progm2GaoJians = programmingBo.searchProgm2GaoJian(programming
					.getId());
		}
		return view("listDaoYu.jsp");
	}

	/**
	 * 跳转到新闻播出人员信息维护页面
	 * 
	 * @return
	 * @since chendan 2010-2-16
	 */
	public String toProStaff() {
		// 先查询ProstaffInfo
		if (programming != null) {
			programming = programmingBo.getProgramming(programming);
			proStaffInfo = programmingBo.searchProStaffInfo(programming);
			programmingBo.check(programming);
		}
		return view("editProgramStaff.jsp");
	}

	/**
	 * 查询新闻栏目人员信息
	 * 
	 * @return
	 * @since chendan 2010-3-14
	 */
	public String searchProStaff() {
		// 先查询ProstaffInfo
		if (programming != null) {
			programming = programmingBo.getProgramming(programming);
			proStaffInfo = programmingBo.searchProStaffInfo(programming);
			programmingBo.check(programming);
		}
		return view("searchProgramStaff.jsp");
	}

	/**
	 * 打印新闻播出单
	 * 
	 * @return
	 * @since chendan 2010-3-4
	 */
	public String printProgram() {
		setDecType(-1);
		programmingModel = programmingBo.getProgrammingModel(programming);
		return view("printProgram.jsp");
	}

	public String searchManuscript() {
		if (searchManuscriptModel != null) {
			gradeManuscriptModels = programmingBo
					.getManuscript(searchManuscriptModel);
		}
		return view("gaoJianGrade.jsp");
	}

	/**
	 * 进入出像统计页面
	 * 
	 * @return
	 * @since chendan 2010-3-15
	 */
	public String toCount() {
		return view("countPhoto.jsp");
	}

	/**
	 * 统计出像次数
	 * 
	 * @return
	 * @since chendan 2010-3-15
	 */
	public String countPhoto() {
		countList = programmingBo.countPhoto(programming, beginDate, endDate,
				userId);
		return view("countPhoto.jsp");
	}

	/**
	 * 获取稿件的录用串联单
	 * 
	 * @return
	 * @since ChenDan 2010-8-8
	 */
	public String getProgrammingsByMans() {
		programmings = programmingBo.getProgrammingByManus(manusId);
		return view("listUsedManuProgram.jsp");
	}

	public Programming getProgramming() {
		return programming;
	}

	public void setProgramming(Programming programming) {
		this.programming = programming;
	}

	public List<Progm2GaoJian> getProgm2GaoJians() {
		return progm2GaoJians;
	}

	public void setProgm2GaoJians(List<Progm2GaoJian> progm2GaoJians) {
		this.progm2GaoJians = progm2GaoJians;
	}

	public String getIdlist() {
		return idlist;
	}

	public void setIdlist(String idlist) {
		this.idlist = idlist;
	}

	public Manuscript getManuscript() {
		return manuscript;
	}

	public void setManuscript(Manuscript manuscript) {
		this.manuscript = manuscript;
	}

	public Object[] getProgm2GaoJiansA() {
		return progm2GaoJiansA;
	}

	public void setProgm2GaoJiansA(Object[] progm2GaoJiansA) {
		this.progm2GaoJiansA = progm2GaoJiansA;
	}

	public List<GradeManuscriptModel> getGradeManuscriptModels() {
		return gradeManuscriptModels;
	}

	public void setGradeManuscriptModels(
			List<GradeManuscriptModel> gradeManuscriptModels) {
		this.gradeManuscriptModels = gradeManuscriptModels;
	}

	public ProStaffInfo getProStaffInfo() {
		return proStaffInfo;
	}

	public void setProStaffInfo(ProStaffInfo proStaffInfo) {
		this.proStaffInfo = proStaffInfo;
	}

	public boolean isChangeOrder() {
		return changeOrder;
	}

	public void setChangeOrder(boolean changeOrder) {
		this.changeOrder = changeOrder;
	}

	public List<Programming> getProgrammings() {
		return programmings;
	}

	public void setProgrammings(List<Programming> programmings) {
		this.programmings = programmings;
	}
}
